<? 
require("adm_header.php"); 
writeCommonAdminTable(LA_ADMIN_HIST_OVERVIEW,1);
echo "<b>".LA_ADMIN_HIST_OVERVIEW."</b><br />";
echo LA_ADMIN_HIST_OVERVIEW_DESCR;
echo "<br /><br />";
//  aWhat	1=Login,2=Contact Person,3=Reset Password,4=Tell a friend,5=Register,6=New ad,7=Update ad,8=Rate Ad,9=Rate User,10=Delete ad
// 11=Member Notify,12=Member Update Personal,13=Failed Login,14=Resend Password,15=Change Password
$lAction[1]="Login";
$lAction[2]="Contact Person";
$lAction[3]="Reset Password";
$lAction[4]="Tell-A-Friend";
$lAction[5]="New User";
$lAction[6]="New Ad";
$lAction[7]="Update Ad";
$lAction[8]="Rate Ad";
$lAction[9]="Rate User";
$lAction[10]="Delete Ad";
$lAction[11]="Notify Update";
$lAction[12]="Update Member Info";
$lAction[13]="Failed Login";
$lAction[14]="Resend Password";
$lAction[15]="Change Password";
$lAction[16]="Refresh (deactivated)";
$lAction[17]="Rss refresh";
$lAction[18]="Update";

function getUsernameFromID($aID)
{
	global $usr_tbl;
	$sql="select user_name from $usr_tbl where user_id=$aID limit 1";
	$res=q($sql);
	$row=mysql_fetch_array($res);
	return $row["user_name"];
}

function getTitleFromAdID($aID)
{
	global $ads_tbl;
	$sql="select ad_title from $ads_tbl where ad_id=$aID limit 1";
	$res=q($sql);
	$row=mysql_fetch_array($res);
	return dotString($row["ad_title"],10);
}


$sql="select * from $hist_tbl order by hist_id desc";
$res=q($sql);
$num=mysql_num_rows($res);

echo "<table width='100%' cellpadding='0' cellspacing='0'><tr class='trHeadLine'><td>".LA_ADMIN_HIST_WHEN."</td><td>".LA_ADMIN_HIST_WHAT."</td><td>".LA_ADMIN_HIST_USER."</td><td>".LA_ADMIN_HIST_AD."</td><td>".LA_ADMIN_HIST_IP."</td><td>".LA_ADMIN_HIST_TEXT."</td></tr>";
while ($row=mysql_fetch_array($res))
{
	$lHistId=$row["hist_id"];
	$lHistWhen=$row["hist_when"];
	$lHistWhat=strEnc($lAction[$row["hist_what"]]);
	$lHistUser=strEnc($row["hist_user"]);
	$lHistAd=$row["hist_ad"];
	$lHistIP=$row["hist_ip"];
	$lHistMsg=strEnc(dotString($row["hist_msg"],10));
	
	if ($lHistUser)
		$lHistUser="<a href='adm_user_list.php?find=$lHistUser'>" . strEnc(getUsernameFromID($lHistUser)) . "</a>";
	if ($lHistAd)
		$lHistAd="<a href='adm_classifieds_list.php?ad_id_show=$lHistAd'>" . strEnc(getTitleFromAdID($lHistAd)) . "</a>";
		
	echo "<tr>";
	

	echo "<td>".formatDateShort($lHistWhen)." " . formatDateClock($lHistWhen)  . "</td>";
	echo "<td>$lHistWhat</td>";
	echo "<td>$lHistUser</td>";
	echo "<td>$lHistAd</td>";
	echo "<td>$lHistIP</td>";
	echo "<td>$lHistMsg</td>";
	
	echo "</tr>";
	
}
echo "</table>";

if ($num==0)
{
	echo "<p>".LA_ADMIN_HIST_NONE."</p>";
	
	
}

echo "<p></p><b>".LA_ADMIN_HIST_LOGGED.":<br /></b>" ;

echo "<table width='100%'><tr><td valign='top'>";
$lCount=0;

foreach ($lAction as $lItem)
{
	echo "$lItem<br />";
	
	$lCount++;
	if ($lCount==4)
	{
		$lCount=0;
		echo "</td><td valign='top'>";
	}
	
	
	
}
echo "</tr></table>";
writeCommonAdminTable("","");
require("adm_footer.php"); 
?>